package com.hessentec.controller;

import com.hessentec.model.Demo;
import com.hessentec.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by songzj on 2016/10/8.
 */
@Controller("demoController")
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private DemoService demoService;

    @RequestMapping("/{id}")
    public String find(@PathVariable("id") Integer id, Model model) {
        Demo demo =  this.demoService.find(id);
        if (demo == null){
            demo = new Demo();
        }
        model.addAttribute("demo",demo);
        return "demo/find"; //tempates目录下找到demo目录下的find.ftl渲染
    }

}
